#ifndef LCD_STRUCT

#define MAX_CHAR_NUM    20
#define MAX_ITEM_NUM    20
#define MAX_CHILD_NUM   16
#define LINE_DIS        2
#define PAGE_SIZE       10
#define STRINGLEN       16

/*
    flag
 */
#define FOLDER          1
#define FILE            0
/*
    value type
 */
#define     STRING      3
#define     FLOAT       2
#define     INTEGER     1
#define     NONE        0

struct Str_item
{
    unsigned char a[8][STRINGLEN];
    unsigned char len;
};

struct Item
{
    unsigned char       ctx[MAX_CHAR_NUM];
    unsigned char       id;
    unsigned char       ctx_len;
    unsigned char       flag;
    unsigned char       value_type;
    unsigned char       realtime;
    void*               p_value;
    unsigned short      limit[2];
    struct Str_item     *p_str_item;

    void                (*func_enter)(void* parg);
    void                (*func_exec)(void* parg);
    void                (*func_input_callback)(void* parg);
    void                (*func_back)(void* parg);
};

struct Node
{
    unsigned char   itemnum;
    unsigned char   page_num;
    unsigned char   page_index;
    unsigned char   node_id;
    struct Item*    p_item;
    unsigned short   position[2];
    struct Node*    parent;
    struct Node*    child[MAX_ITEM_NUM];
    void            (*init)(void *parg);
    void            (*save)();
};

struct Status
{
    struct Node*    p_current;
    struct Item*    p_item;
    unsigned char   is_input;
    unsigned char   is_run;
};

struct Lcd
{
    struct Node*    root_node;
    struct Status*  p_status;
    unsigned char   key;
    char            update_flag;
    char            flag_key;
    void            (*init)();
    void            (*process)(char key);
    void            (*show_run)();
    void            (*input)(void* parg);
    signed char     (*add_to_watch)(unsigned char* p_str, unsigned char is_int, void* p_value);
};

static void nop(void *parg)
{

}

static struct Node empty_n = 
{
    .init = nop,
    .parent = &empty_n
};
#define LCD_STRUCT
#endif
